package cn.com.dao;

import java.util.ArrayList;
import java.util.List;

import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.Transaction;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import cn.com.entity.KeShi;
import cn.com.entity.LiuYan;

public class LiuYanDao {
	private SessionFactory sessionFactory;

	public SessionFactory getSessionFactory() {
		return sessionFactory;
	}

	public void setSessionFactory(SessionFactory sessionFactory) {
		this.sessionFactory = sessionFactory;
	}

	Session session;
	Transaction transaction;
	public List<LiuYan> getall(){
		session=sessionFactory.openSession();
		String hql="from LiuYan";
		Query query=session.createQuery(hql);
		List<LiuYan> liuyanlist=query.list();
		return liuyanlist;
	}
	public boolean insertliuyan(LiuYan liuyan){
		boolean b=false;
		session=sessionFactory.openSession();
		transaction=session.beginTransaction();
		if(liuyan!=null){
			session.save(liuyan);
			transaction.commit();
			session.close();
			b=true;
		}
		return b;
	}
	
}
